<!DOCTYPE html>
<html>

	<head>
		<meta charset="utf-8" />
		<title></title>
		<style type="text/css">
			* {
				padding: 0;
				margin: 0;
			}
			
			.container {
				width: 100vw;
				height: 100vh;
				display: flex;
				align-items: center;
				justify-content: center;
			}
			
			canvas {
				width: 500px;
				height: 500px;
				border: 2px solid blue;
			}
		</style>
	</head>

	<body>
		<div id="answer"></div>
		<div class="container">
			<canvas id="canvas" width="500" height="500"></canvas>
		</div>
	</body>
	<script type="text/javascript">
		window.onload = function() {
			var oAnswer = document.getElementById("answer");
			let n = 10;
			let str = "";
			for(var i = 1; i < n; i++) {
				for(var j = 0; j < n - i; j++) {
					str += " ";
				}
				for(var j = 0; j < i * 2 - 1; j++) {
					str += "*";
				}
				str +="</br>";
				str += "\n";
			}
			oAnswer.innerHTML = str;
			console.log(str);

			let oCanvas = document.getElementById('canvas');

			console.dir(oCanvas);

			let oPen = oCanvas.getContext("2d");

			console.dir(oPen);
		}
	</script>
	</body>

</html>